package gui;

import java.awt.*;

import javax.swing.JFrame;

/*
 * Creates a Motif Graph presentation
 */
public class MotifGraph {

	JFrame frm;
	
	long totalSize;
	
	/*
	 * Layout parameters
	 */
	private int x = 50,y = 50,height = 2;
	private int margin = 5;
	private int width = 5000;
	private int stringHeight = 20;
	
	public MotifGraph(long totalSize)
	{
		this.totalSize = totalSize;
		frm = new JFrame("Motif Graph");
		frm.setResizable(false);
		frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frm.setSize(2000,200);
		frm.setBackground(Color.WHITE);
		frm.show();
	}
	
	public void showFrame(long[] location) 
	{
		Graphics g = frm.getGraphics();
		g.setColor(Color.BLUE);
		g.drawLine(x + 10,y, x + 10, y + height);
		//g.drawLine(x + 100 + width,y, x + 100 + width, y + motifs.length*(height + margin));
		g.setColor(Color.BLACK);
		
		int lastPoint = 0;
		int lastPointCount = 0;
		for(int i=0 ; i<location.length ; i++)
		{	
			//g.drawString(location[i], x, y + i*(height + margin) + stringHeight);
			//for( int j=0; j<lines.length; j++)
			//{
				long point = (location[i] * width) / totalSize;
				if (lastPoint == (int)point)
					lastPointCount++;
				else
				{
					g.drawLine(x + 10 + lastPoint, y , x + 10 + lastPoint, y + lastPointCount * height);
					System.out.println(lastPointCount);
					lastPoint = (int)point;
					lastPointCount = 0 ;
				}
			//}
		}
		
		int x = 0;
		x++;
	}

}
